home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 38
/
Amiga Format CD38 (1999-03-15)(Future Publishing)(GB)(Track 1 of 3)[!][issue 1999-04].iso
/
-seriously_amiga-
/
misc
/
football
/
exec
/
lstats.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1999-02-03
|
12KB
|
386 lines
/* ***********************************************************************
LEAGUE STATS PROGRAM FOR FOOTBALL REXX SUITE
----------------------------------------------
Copyright Mark Naughton 1996
Version Date History
--------------------------------------------------------------------------
1.0 211196 First release. Displays info about the league and then
the best record/performance in the league.
211196 Steve Holland has helped immensely in improving the
display and in what stats to display.
1.1 110497 Added code to support Points_Per_Goals.
120497 Removed code that adds Points for Goals as the
performance options were too far out. A team with a
246% record out of 5 matches is too much. Points Per
Goals is now mentioned but is NOT used.
160597 Amended way the number of matches is incremented. Was
adding an extra one.
1.2 250997 Added code for promotions and divisions.
071297 Amended Highest Home/Away win as 7-0 should be better
than 7-2.
151297 Tidied display.
160998 Added code to give priority to teams with less goals
scored against them. Added code to display all matches
which match the highest home/away scores.
250199 Fixed bugs in calculating the biggest wins where if the
match had a clean sheet, no other match could top it
unless they had a clean sheet and scored more goals.
**************************************************************************
Procedure
---------
1. Check files exist. Open 'Teams.df' file and read data into array/variables.
2. Open Learn file and read a line.
3. Store data on the teams that played a match (Win/Draw/Loss) for Record
and Performance.
4. Store stats for the league.
5. Calculate the biggest win/loss.
6. Format data produced for Record and Performance.
7. Display data then exit...
************************************************************************** */
PARSE ARG league_stuff
version = 1
input_file = '.df'
input2_file = '.sflearn'
title = '*LEAGUE_NAME='
points_win = '*POINTS_PER_WIN='
points_drw = '*POINTS_PER_DRW='
points_lse = '*POINTS_PER_LSE='
points_gls = '*POINTS_PER_GLS='
releg = '*RELEGATION='
playother = '*PLAY_OTHER='
promoted = '*PROMOTED='
num_divs = '*NUM_DIVISIONS='
divisions = '*DIVISIONS='
pkauthor = '* Author ='
pkversion = '* Version='
pkdate = '* Date ='
separator = '*'
not_played = '__ __'
teams. = '???'
records. = '???'
undefeat. = '???'
ustring. = '???'
rstring. = '???'
mats. = '???'
pct. = '???'
tcount = 0
lversion = '1.0'
lreg = 2
lplayo = 2
ptsgls = 0
ndivs = 1
promo = 0
divs = ''
parse var league_stuff league_file
league_file = "Data/" || league_file
if exists(league_file || input_file) = 0 then exit
if exists(league_file || input2_file) = 0 then exit
if open(datafile,league_file || input_file,'r') then do
do while ~eof(datafile)
line = readln(datafile)
if pos(title,line) > 0 then league_title = delstr(line,1,13)
if pos(pkauthor,line) > 0 then author = delstr(line,1,12)
if pos(pkversion,line) > 0 then lversion = delstr(line,1,12)
if pos(pkdate,line) > 0 then ddate = delstr(line,1,12)
if pos(points_win,line) > 0 then ptswin = delstr(line,1,16)
if pos(points_drw,line) > 0 then ptsdrw = delstr(line,1,16)
if pos(points_lse,line) > 0 then ptslse = delstr(line,1,16)
if pos(points_gls,line) > 0 then ptsgls = delstr(line,1,16)
if pos(releg,line) > 0 then lreg = delstr(line,1,12)
if pos(playother,line) > 0 then lplayo = delstr(line,1,12)
if pos(promoted,line) > 0 then promo = delstr(line,1,10)
if pos(num_divs,line) > 0 then ndivs = delstr(line,1,15)
if pos(divisions,line) > 0 then divs = delstr(line,1,11)
if pos(separator,line) = 0 then do
line = strip(line)
tcount = tcount + 1
teams.tcount = line
records.tcount = 0
undefeat.tcount= ''
mats.tcount = 0
pct.tcount = 0
end
end
close(datafile)
end
else do
say
say "ERROR : (LStats / League Information)"
say
say "Cannot open '"league_file||input_file"' for reading."
exit
end
line_ct = 0
matches = 0
high_df = 0
high_ht = ''
high_at = ''
high_hw = 0
high_aw = 0
high_hs = 0
high_as = 0
draws = 0
hwins = 0
awins = 0
type = 0
hcls = 99
acls = 99
nlines. = '???'
nlcnt = 0
if open(datafile,league_file || input2_file,'r') then do
do while ~eof(datafile)
line_ct = line_ct + 1
line = readln(datafile)
if pos(separator,line) = 0 then do
if pos(not_played,line) = 0 then do
home_team = strip(substr(line,1,30))
goals_for = substr(line,32,2)
goals_aga = substr(line,37,2)
away_team = strip(substr(line,41,30))
call save_data(home_team,away_team,goals_for,goals_aga)
if home_team ~= away_team & home_team ~= '' & away_team ~= '' then
matches = matches + 1
diff = 0
if goals_for = goals_aga & home_team ~= away_team then do
draws = draws + 1
type = 0
end
if goals_for > goals_aga then do
hwins = hwins + 1
diff = goals_for - goals_aga
type = 1
end
if goals_for < goals_aga then do
awins = awins + 1
diff = goals_aga - goals_for
type = 2
end
if type = 1 then do
if diff >= high_hw then do
nlcnt = nlcnt + 1
nlines.nlcnt = line
if ((goals_for > high_hs) | (diff = goals_for)) | (diff = high_hw & goals_aga <= hcls) then do
high_hw = diff
hcls = goals_aga
high_hs = goals_for
high_ht = line
end
end
end
if type = 2 then do
if diff >= high_aw then do
nlcnt = nlcnt + 1
nlines.nlcnt = line
if ((goals_aga > high_as) | (diff = goals_aga)) | (diff = high_aw & goals_for <= acls) then do
high_as = goals_aga
high_at = line
high_aw = diff
acls = goals_for
end
end
end
type = 0
end
end
end
close(datafile)
r = 0
rc = 0
u = 1
uc = 0
do i=1 to tcount
pct.i = trunc((records.i/(mats.i*ptswin) * 100),1)
if pct.i > r then r = pct.i
end
do i=1 to tcount
if pct.i = r then do
rc = rc + 1
rstring.rc = teams.i || " with " || records.i || "pts from " || mats.i || " matches. ( " || pct.i || "% )"
end
end
do i=1 to tcount
if length(undefeat.i) > u then
u = length(undefeat.i)
end
do i=1 to tcount
if length(undefeat.i) = u then do
uc = uc + 1
undefeat.i=strip(undefeat.i)
ucn = (length(undefeat.i) * 2) - 1
call format_perf(undefeat.i,ucn)
if ucn = 1 then ptemp = undefeat.i
if length(ptemp) > 0 then
ustring.uc = " " || left(teams.i,30) || " (" || ptemp || ")"
end
end
hmw = trunc((hwins/matches) * 100,1)
dm = trunc((draws/matches) * 100,1)
amw = trunc((awins/matches) * 100,1)
hwins = centre(hwins,5)
draws = centre(draws,5)
awins = centre(awins,5)
say
say center("League Information for '"league_title"'",78)
say "-------------------------------------------------------------------------------"
say
say " Author : "author
say " Created: "ddate
say " Version: "lversion
say
say "Matches played : "matches
say
say "Home Wins : "hwins" ( "hmw"% )"
say "Draws : "draws" ( "dm"% )"
say "Away Wins : "awins" ( "amw"% )"
say
say "Points For Win : "ptswin
say "Points For Draw : "ptsdrw
say "Points For Loss : "ptslse
say "Points Per Goal : "ptsgls" (NOT used for Best Record/Undefeated Run)"
say
say "Number of Teams Promoted : "promo
say "Number of Teams Relegated : "lreg
say "Play Each Team : "lplayo
say
say "Number of Related Divisions: "ndivs - 1
say "Related Divisions : "divs
say "_______________________________________________________________________________"
say
say "Biggest Home Win (Priority given to teams with less goals scored against)"
say "----------------"
say
hline = substr(high_ht,32,2)" "substr(high_ht,37,2)
if hline ~= "" then do
do i=1 to nlcnt
if pos(hline,nlines.i) > 0 then
say nlines.i
end
end
else
say "None found."
say
say "Biggest Away Win"
say "----------------"
say
aline = substr(high_at,32,2)" "substr(high_at,37,2)
if aline ~= "" then do
do i=1 to nlcnt
if pos(aline,nlines.i) > 0 then
say nlines.i
end
end
else
say "None found."
say "_______________________________________________________________________________"
say
say "Best Record"
say "-----------"
say
do i=1 to rc
say rstring.i
end
say
say
say "Current Best Undefeated Run"
say "---------------------------"
say
ustring.1 = overlay(u || " games :",ustring.1,1)
do i=1 to uc
say ustring.i
end
say
say "-------------------------------------------------------------------------------"
end
else do
say
say "ERROR : (LStats / League Information)"
say
say "Cannot open '"league_file||input2_file"' for reading."
exit
end
exit
/* Routine ---------------------------------------------------------- */
save_data:
PARSE ARG homet,awayt,gf,ga
h = 0
a = 0
do i=1 to tcount
if pos(strip(homet),teams.i) > 0 then do
h = i
mats.i = mats.i + 1
end
if pos(strip(awayt),teams.i) > 0 then do
mats.i = mats.i + 1
a = i
end
end
if a = 0 | h = 0 then return
if gf > ga then do
records.h = records.h + ptswin
records.a = records.a + ptslse
undefeat.h = insert('W',undefeat.h,length(undefeat.h),1)
undefeat.a = ''
end
if gf < ga then do
records.a = records.a + ptswin
records.h = records.h + ptslse
undefeat.a = insert('W',undefeat.a,length(undefeat.a),1)
undefeat.h = ''
end
if gf = ga then do
records.a = records.a + ptsdrw
records.h = records.h + ptsdrw
undefeat.a = insert('D',undefeat.a,length(undefeat.a),1)
undefeat.h = insert('D',undefeat.h,length(undefeat.h),1)
end
/*
records.a = records.a + (ga * ptsgls) PTS_PER_GLS - NOT USED FOR PERFORMANCE...
records.h = records.h + (gf * ptsgls)
*/
return
/* Routine ---------------------------------------------------------- */
format_perf:
ARG fstrg,counter
ptemp = ''
ii = 1
jj = 1
do while ii <= counter
ptemp = insert(substr(fstrg,jj,1),ptemp,ii,1)
ii = ii + 1
jj = jj + 1
if ii < counter then do
ptemp = insert(".",ptemp,ii,1)
ii = ii + 1
end
end
ptemp = strip(ptemp)
return
/* ------------------------------------------------------------------ */